package com.qingluan.geo;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.util.Log;

import com.baidu.mapapi.map.ItemizedOverlay;
import com.baidu.mapapi.map.MapController;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayItem;
import com.baidu.platform.comapi.basestruct.GeoPoint;
import com.qingluan.dd.MapModel;
import com.qingluan.dd.OnePointDetailInfo;

public class GeoPersonalOverlay extends ItemizedOverlay<OverlayItem> {

	private static String tag = GeoPersonalOverlay.class.getName();
	private Activity oneActivity;
	private Class<?> toActivity;
	private MapController controller;
	public GeoPersonalOverlay(Drawable layer, MapView mapView) {
		
		super(layer, mapView);
		// TODO Auto-generated constructor stub
	}
	
	public void setCallActivity(Activity source,Class<?> destination){
		this.oneActivity = source;
		this.toActivity = destination;
	}
	
	public void setMapController (MapController mapController){
		controller = mapController;
	}
	@Override
	public boolean onTap(GeoPoint p, MapView mapView) {
		return super.onTap(p, mapView);
	}

	/**
	 * 覆盖这个方法去处理一个item上的点击事件。 这可能是对屏幕上item的触摸点击，或者对位于中心且已选定的item的跟踪球点击。默认情况下，什么都不做，返回false
	 * 如果点击事件被处理，返回true；如果想要把这个事件传递给其它overlay，返回false
	 */
	@Override
	protected boolean onTap(int index) {
		controller.animateTo(getItem(index).getPoint());
//		controller.setZoom(14);

		Log.d(tag,"第" + index + "个点被点击");
		Intent intent = new Intent(oneActivity.getApplicationContext(),toActivity);
		OverlayItem item = this.getItem(index);
		
		intent.putExtra("title", item.getTitle());
		
		oneActivity.startActivity(intent);
		return false;
	}

}
